library(ggplot2)
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
base<-read.csv("../data/UIID_statusdx.csv",header=T)
class(base)
## [1] "data.frame"
base<-base%>%
as_data_frame()%>%
mutate(EstatusDx=as.character(ESTATUDX),
EstatusDx=if_else(ESTATUDX==0,"C. Sin IDP",EstatusDx),
EstatusDx=if_else(ESTATUDX==1,"B. Con IDP",EstatusDx),
EstatusDx=if_else(ESTATUDX==2,"A. IDP en estudio",EstatusDx))
class(base)
## [1] "tbl_df" "tbl" "data.frame"
base
gg01<-ggplot(data=base,aes(x=aniocons, fill=EstatusDx)) +
geom_density(adjust=1.5, position="fill")
# gg01
gg01_pl<-ggplotly(gg01)
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
gg01_pl$x$layout$xaxis$title<-"Año de consulta"
gg01_pl$x$layout$yaxis$title<-"densidad"
gg01_pl
El porcentaje de pacientes diagnosticados con IDP se mantiene constate o estable alrededor del 30%.
Se observa que antes (2011) había una mayor proporción de casos en los que se descartaba IDP y, que hoy, parte de esa propoción de casos (~30%), pasó a ser IDP en estudio, mostrando ser hoy más minuciosos para confirmar o descartar el diagnóstico.
gb01<-base%>%
group_by(aniocons)%>%
summarise(n_px=n(),
per_px=round(n_px/nrow(.),4))
gb01
gb02<-base%>%
group_by(aniocons)%>%
mutate(n_px=n()#,
# per_px=round(n_px/nrow(.),4)
)%>%
ungroup()%>%
group_by(aniocons,ESTATUDX)%>%
mutate(n_st_anio=n(),
per_st_anio=round(n_st_anio/n_px,4))%>%
filter(row_number()==1)%>%
select(-Expediente)
gb02
gg02 <-ggplot(gb02, aes(aniocons, n_st_anio))+
geom_bar(stat = "identity", aes(fill = EstatusDx))
# gg02
gg02_pl<-ggplotly(gg01)
## We recommend that you use the dev version of ggplot2 with `ggplotly()`
## Install it with: `devtools::install_github('hadley/ggplot2')`
gg02_pl$x$layout$xaxis$title<-"Año de consulta"
gg02_pl$x$layout$yaxis$title<-"Frecuencia de casos"
gg02_pl